<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:ubb="http://java.sun.com/jsf/composite/components">

    <p:dataTable value="#{userManager.users}" var="user" emptyMessage="#{msg['adminPage.userManagement.users.emptyTable']}..."
                 filteredValue="#{userManager.filteredUsers}" rendered="#{administrationView.activePanel == 'LIST_USERS'}"  rowIndexVar="userIndex">
        <p:columnGroup type="header">
            <p:row>
                <p:column headerText="#{msg['adminPage.userManagement.users.username']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.firstName']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.lastName']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.sex']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.age']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.email']}" />
                <p:column headerText="#{msg['adminPage.userManagement.users.state']}" />
                <p:column colspan="2" headerText="#{msg['adminPage.userManagement.users.group']}" />
            </p:row>
            <p:row>
                <p:column filterBy="#{user.username}" filterMatchMode="contains" />
                <p:column filterBy="#{user.firstname}" filterMatchMode="contains" />
                <p:column filterBy="#{user.lastname}" filterMatchMode="contains" />
                <p:column filterBy="#{user.sex}" filterMatchMode="exact" filterOptions="#{userManager.sexFilterOptions}" />
                <p:column filterBy="#{user.age}" filterMatchMode="contains" />
                <p:column filterBy="#{user.email}" filterMatchMode="contains" />
                <p:column filterBy="#{user.state}" filterMatchMode="exact" filterOptions="#{userManager.stateFilterOptions}" />
                <p:column filterBy="#{user.group.groupName}" filterMatchMode="contains" />
                <p:column style="background:transparent" />
            </p:row>
        </p:columnGroup>
        <p:column>
            <h:outputText value="#{user.username}" />
        </p:column>
        <p:column>
            <h:outputText value="#{user.firstname}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{user.lastname}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{msg['adminPage.userManagement.users.sex.male']}" rendered="#{user.sex}"/>
            <h:outputText value="#{msg['adminPage.userManagement.users.sex.female']}" rendered="#{!user.sex}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{user.age}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{user.email}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{msg['adminPage.userManagement.users.state.active']}" rendered="#{user.state}"/>
            <h:outputText value="#{msg['adminPage.userManagement.users.state.inactive']}" rendered="#{!user.state}"/>
        </p:column>
        <p:column>
            <h:outputText value="#{user.group.groupName}"/>
        </p:column>
        <p:column styleClass="actions">
            <p:commandLink action="#{userManager.edit(user)}" update="@form" >
                <h:graphicImage library="images" name="edit-16.png" />
                <h:outputText value="#{msg['Common.edit']}" />
            </p:commandLink>
            <p:commandLink onclick="confirmUserDelete#{userIndex}.show();return false;">
                <h:graphicImage library="images" name="trash-16.png" />
                <h:outputText value="#{msg['Common.delete']}" />
            </p:commandLink>
            <p:commandLink id="deleteUser" action="#{userManager.delete(user)}" update="@form" value="Execute" style="display: none" />
            <ubb:confirmationDialog title="#{msg['adminPage.userManagement.users.delete.confirmationTitle']}" message="#{msg['adminPage.userManagement.users.delete.confirmationMessage']}"
                                    actionButtonId="#{p:component('deleteUser')}" widgetVar="confirmUserDelete#{userIndex}" />
        </p:column>
    </p:dataTable>
    <h:panelGroup rendered="#{administrationView.activePanel == 'LIST_USERS'}" layout="block" styleClass="buttonPanel">
        <p:commandButton value="#{msg['adminPage.userManagement.users.createNew']}" action="#{administrationView.switchPanel('NEW_USER')}" update="@form" icon="add" process="@this" />
        <p:commandButton value="#{msg['Common.cancel']}" action="#{administrationView.switchPanel('DESCRIPTION')}" update="@form" icon="cancel" process="@this" />
    </h:panelGroup>
</ui:composition>